

/**
 * 预加载
 */
class InfiniteScroll {
    constructor(options,callback) {
        let el = options.el || '.scrollerFooter';
        let root = null;
        if(options.root) {
            root = document.querySelector(options.root);
        }
        let advance = options.advance || 300;
        advance += 'px';
        let opt = {
            root:root,
            rootMargin:'0px 0px '+advance+' 0px'
        };
        this.item = document.querySelector(el);
        this.io = new IntersectionObserver((entries)=>{
            console.log(entries[0]);
            if(entries[0].isIntersecting) {
                callback(entries[0]);
            }
        },opt);
        this.io.observe(this.item);     
    }
}

export default InfiniteScroll;